import axios from "./axios"
// 获取验证码数据
export const getCaptchas = () => {
  return axios.post("v1/captchas").catch(err => { console.log(err) });
}
// 获取用户信息
export const getUser = (user_id) => {
  return axios.get("v1/user?user_id="+user_id).catch(err=>{console.log(err)});
}
// 获取登录数据
export const getLogin = (username, password,captcha_code) => {
  return axios.post("v2/login",{
    username: username,
    password:password,
    captcha_code: String(captcha_code),
  }).catch(err => { console.log(err) });
}

//热门城市
export const getHotCity=()=>{
   return   axios.get('v1/cities?type=hot').catch(err=>{
       console.log(err);
   })
}
//定位城市
export const getLocatCity=()=>{
    return axios.get('v1/cities?type=guess').catch(err=>{
        console.log(err);
    })
}

//所有城市
export const getGroupCity=()=>{
    return axios.get('v1/cities?type=group').catch(err=>{
        console.log(err);
    })
}


//获取所选城市信息
export const deliverCity=(cityId)=>{
    return  axios.get('v1/cities/'+cityId).catch(err=>{
        console.log(err);
    })
}

//获取附近商家
export const getNearShop=(latitude,longitude)=>{
    return   axios.get('shopping/restaurants'+'?latitude='+latitude+'&longitude='+longitude).catch(err=>{
        console.log(err);
    })
}

// https://elm.cangdu.org/v4/restaurants?geohash=31.22967,121.4762&keyword=肯德基

// https://elm.cangdu.org/shopping/restaurants?latitude=31.22967&longitude=121.4762


// https://elm.cangdu.org/shopping/restaurant/:shopid
export const getInputData=(geohash,keyword)=>axios.get('v4/restaurants'+"?"+"geohash="+geohash+"&keyword="+keyword).catch(err=>console.log(err))
export const getMallInfo=(index)=>axios.get('shopping/restaurant/'+index).catch(err=>console.log(err))

export const getevaluteData=(id)=>axios.get('ugc/v2/restaurants/'+id+'/ratings/scores').catch(err=>console.log(err))
